package com.rw.coco.service;

import com.rw.coco.api.data.PersistenceMapper;
import com.rw.coco.api.data.TransactionSwitch;
import com.rw.coco.api.data.persistence.*;
import com.rw.coco.handler.message.event.CocoMessageEvent;

/**
 * 持久化操作service
 */
public abstract class BaseService {
    protected final PersistenceMapper mapper;

    protected final AccountMapper accountMapper;

    protected final BotMapper botMapper;

    protected final DeckMapper deckMapper;

    protected final GroupMapper groupMapper;

    protected final ObMapper obMapper;

    protected final CharacterMapper characterMapper;

    protected final CharacterPropertyMapper characterPropertyMapper;

    protected final CardMapper cardMapper;

    protected final TransactionSwitch transactionSwitch;

    public BaseService(PersistenceMapper mapper) {
        this.mapper = mapper;
        this.accountMapper = mapper.getAccountMapper();
        this.botMapper = mapper.getBotMapper();
        this.deckMapper = mapper.getDeckMapper();
        this.groupMapper = mapper.getGroupMapper();
        this.obMapper = mapper.getObMapper();
        this.characterMapper = mapper.getCharacterMapper();
        this.characterPropertyMapper = mapper.getCharacterPropertyMapper();
        this.cardMapper = mapper.getCardMapper();
        this.transactionSwitch = mapper.getTransactionSwitch();
    }

    public BaseService(CocoMessageEvent cocoMessageEvent) {
        this(cocoMessageEvent.getPersistenceMapper());
    }
}
